package com.kehutong.crm.message.app;

import java.sql.Timestamp;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.util.Objects;
import com.kehutong.common.errcode.Result;
import com.kehutong.common.util.Token;
import com.kehutong.crm.message.entity.MessageNotifyEmployee;
import com.kehutong.crm.message.entity.MessageUser;
import com.kehutong.crm.message.service.MessageService;

/**
 * 企微端-消息管理
 */
@MvcAction
@ReqMapping("/kht-bin/crm/message")
public class MessageAction {

    @Inject
    private MessageService messageService;

    @ReqMapping("/remind/list")
    public Object remindList(Token token, JSONObject jsonObject){
        return Result.success(messageService.remindList(jsonObject, token.getUuid(), token.getCompanyNo(), new Timestamp(token.getUserCreateTime()), false));
    }

    @ReqMapping("/business/read")
    public Object businessRead(String id){
        messageService.businessRead(id);
        return Result.success();
    }

    @ReqMapping("/bulletin/list")
    public Object bulletinList(Token token, JSONObject jsonObject){
        return Result.success(messageService.bulletinList(jsonObject, token.getUuid(), token.getCompanyNo(), new Timestamp(token.getUserCreateTime()), false));
    }

    @ReqMapping("/bulletin/detail")
    public Object bulletinDetail(String id){
        return messageService.bulletinDetail(id);
    }

    @ReqMapping("/workbench/count")
    public Object workbenchCount(Token token){
        return messageService.workbenchCount(token.getUuid());
    }

    @ReqMapping("/del")
    public Object del(String id){
        return messageService.del(id);
    }

    @ReqMapping("/notify/list")
    public Object notifyList(Token token, JSONObject jsonObject) {
        return messageService.employeeMessages(jsonObject, token.getUuid());
    }

    @ReqMapping("/list")
    public Object list(Token token, JSONObject jsonObject) {
        return messageService.listMessageUser(jsonObject, token.getUuid(), new Timestamp(token.getUserCreateTime()), false);
    }

    @ReqMapping("/app/detail")
    public Object appDetail(MessageNotifyEmployee employee) {
        return messageService.appDetail(employee);
    }

    @ReqMapping("/detail")
    public Object detail(MessageUser messageUser) {
        return messageService.detail(messageUser);
    }

    @ReqMapping("/workbench/page")
    public Object workbenchPage(Token token){
        return messageService.workbenchPage(token.getUuid());
    }

}
